<?
global $db;
$release = "`release`";

$e = $db->query1("select * from node where id = ".$db->sqlint($params["id"]));
skin_param("page",$e);
echo "<div>";
echo $e["content"];
echo "</div>";

inc_inclib("image.php");
global $topurl,$topdir;

$r = $db->query("select project.id as pid,project.node_id,project.title,project.image,$release.datetimeon,$release.title as version,$release.id as rid from project,$release where $release.project_id = project.id order by $release.datetimeon desc limit 12"); 

shuffle($r);

for ($i=0; $i<5; $i++) {
	$e = array_pop($r);
	
	$fname = "$topdir/shots/{$e["image"]}";
	if ($e["image"] != "" && file_exists($fname)) {
		echo "<p>";
		echo "<h2>";
// 		echo "<a href=\"$topurl/projects/{$e["node_id"]}/{$e["pid"]}/?release_id={$e["rid"]}\">";
		echo "<a href=\"$topurl/project/{$e["pid"]}/?release_id={$e["rid"]}\">";
		echo "{$e["title"]} - {$e["version"]}";
		echo "</a>";
		echo " - ";
		echo date("M j, Y",strtotime($e["datetimeon"]));
		echo "</h2>";
		
		echo "<p><a href='$topurl/shots/{$e["image"]}' target='_blank'>";
		
		#<img src='$topurl/thumb/".image_thumb($fname,400,300,"png")."' width=400 height=300>";
		
		$img = image_thumb($fname,400,300,"jpg");
		list($iw,$ih) = getimagesize("$topdir/thumb/$img");
		echo "<img src='$topurl/thumb/$img' width=$iw height=$ih>";
		
		echo "<br>click to view original size</a></p>";
		echo "</p>";
		}
	}
?>